package com.ec.api.enumeration;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.ec.common.exception.BusinessException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import static com.ec.common.enumeration.BusinessExceptionEnum.PARAM_ERROR;

@Getter
@AllArgsConstructor
public enum RobotStatus {
    IDLE("待机"),
    WORKING("执行任务"),
    OFFLINE("离线");

    @EnumValue
    @JsonValue
    private final String value;

    public static RobotStatus fromValue(String value) {
        for (RobotStatus robotStatus : RobotStatus.values()) {
            if (robotStatus.getValue().equals(value)) {
                return robotStatus;
            }
        }
        throw new BusinessException(PARAM_ERROR);
    }
}
